#include "protocol.h"

extern unsigned char Tx_DETBuffer[];

static int tx_pos;

 void reset_txbuff(int num)
{
	int i;
	for(i=0;i<num;i++) Tx_DETBuffer[i]=0;
	tx_pos = num;
}
void write_txbuff(unsigned char *point,int type)
{
	int data_num;
	int i;
	switch (type)
	{
	case type_double:data_num=8;break;

	case type_float:
	case type_int32:
	case type_uint32:data_num=4;break;

	case type_int16:
	case type_uint16:data_num=2;break;

	case type_int8:
	case type_uint8:data_num=1;break;

	default:data_num=1;
		break;
	}

#if (defined (BIG_ENDIAN))&&(defined (LITTLE_ENDIAN))
#error "redefine transmit endian"
#elif defined BIG_ENDIAN
for (i=0;i<data_num;i++)
{
	Tx_DETBuffer[data_num-i-1+tx_pos] = point[i];
}
#elif defined (LITTLE_ENDIAN)
for (i=0;i<data_num;i++)
{
	Tx_DETBuffer[i+tx_pos] = point[i];
}
#else 
#error "not define transmit endian"
#endif
tx_pos += data_num;
}


#ifdef STATISTICS
 int STATISTIC_ON = 0;
#endif // STATISTICS



